﻿KISSY.add("fgt/ui/popup", function (S, Component, Overlay) {

    var OFFSET = 10;
    function Popup(container, config) {
        var self = this;

        if (S.isUndefined(config)) {
            config = container;
        } else {
            config.srcNode = container;
        }
        Popup.superclass.constructor.call(self, S.merge({ shadow: true, shadowExtLength: 4, zIndex: 99999 }, config || {}));
    }

    Popup.ATTRS = {
        trigger: {
            setter: function (v) {
                return S.one(v);
            }
        },
        showTriggerType: { value: "mouseenter" },
        hideTriggerType: { value: "mouseleave" },
        showDelay: { value: 0 },
        hideDelay: { value: 100 },
        alignNode: {
            setter: function (v) {
                return S.one(v);
            }
        },
        alignDirCfg: { value: "auto" }, // "auto", "t", "b"
        alignCfg: {
            value: { t: { points: ["tc", "bl"], offset: [0, 0] }, b: { points: ["bc", "tl"], offset: [0, 0]} }
        },
        ajaxLoadCfg: {
            value: {
                enable: false,
                refresh: false
            }
        },
        ajaxLoadEffect: {
            value: {
                loadingHtml: "<div class='loading' style='width: 200px; height: 100px;'><div class='text'><span>加载中...</span></div></div>",
                loadFailureHtml: "<div class='load-failure' style='width: 200px; height: 100px;'><div class='text'><span>加载失败</span></div></div>"
            }
        },
        showArrow: { value: true }
    };

    S.extend(Popup, Overlay, {
        initializer: function () {
            var self = this;

            var trigger = self.get("trigger");
            if (trigger) {
                self._bindTrigger();
                self.on('bindUI', function () {
                    self._bindContainerMouse();
                });
            }

            self.isRender = false;
        },

        _render: function () {
            var self = this,
                showArrow = self.get("showArrow");

            self.render();  //must invoke render() before any operations of access DOM node
            if (showArrow) {
                self._addArrow();
            }
            self.isRender = true;
        },

        _addArrow: function () {
            var self = this,
            //contentEl = self.get("contentEl"),
                el = self.get("el"),
                prefixCls = self.get("prefixCls");
            //contentEl.append("<div class='" + prefixCls + "arrow'></div>");
            el.append("<div class='" + prefixCls + "arrow'></div>");
        },

        _setArrowDirection: function () {
            var self = this,
                direction = self.get("alignDir"),
            //contentEl = self.get("contentEl"),
                el = self.get("el"),
                arrowCls = self.get("prefixCls") + "arrow",
            //arrowNode = contentEl.all("." + arrowCls);
                arrowNode = el.all("." + arrowCls);
            if (direction == "t") {
                arrowNode.removeClass(arrowCls + "-top");
                arrowNode.addClass(arrowCls + "-bottom");
            }
            else if (direction == "b") {
                arrowNode.removeClass(arrowCls + "-bottom");
                arrowNode.addClass(arrowCls + "-top");
            }
        },

        _judgeAlign: function () {
            var self = this,
                alignNode = self.get("alignNode"),
                alignDirCfg = self.get("alignDirCfg");

            if (alignDirCfg == "auto") {
                var el = self.get("el"),
                elHeight = el.outerHeight(),
                win = S.all(window),
                alignNodeOffset = alignNode.offset(),
                alignNodeWidth = alignNode.width(),
                topHeight = alignNodeOffset.top - win.scrollTop();
                if (topHeight >= (elHeight + OFFSET)) {
                    self.set("alignDir", "t");
                }
                else {
                    self.set("alignDir", "b");
                }
            }
            else {
                self.set("alignDir", alignDirCfg);
            }
        },

        _setAlign: function () {
            var self = this,
                direction = self.get("alignDir"),
                alignNode = self.get("alignNode"),
                alignCfg = self.get("alignCfg"),
                dirCfg = alignCfg[direction];
            if (direction == "t") {
                //self.align(alignNode, dirCfg.points, [dirCfg.offset[0], -OFFSET + dirCfg.offset[1]]);
                self.set("align", {
                    node: alignNode,
                    points: dirCfg.points,
                    offset: [dirCfg.offset[0], -OFFSET + dirCfg.offset[1]]
                });
            }
            else if (direction == "b") {
                //self.align(alignNode, dirCfg.points, [dirCfg.offset[0], OFFSET + dirCfg.offset[1]]);
                self.set("align", {
                    node: alignNode,
                    points: dirCfg.points,
                    offset: [dirCfg.offset[0], OFFSET + dirCfg.offset[1]]
                });
            }
        },

        reposition: function () {
            var self = this,
                showArrow = self.get("showArrow");

            self._judgeAlign();
            self._setAlign();
            if (showArrow) {
                self._setArrowDirection();
            }
            self.resizeShadow();
        },

        _ajaxLoad: function () {
            var self = this,
                J = jQuery,
                contentEl = self.get("contentEl"),
                ajaxLoadCfg = self.get("ajaxLoadCfg"),
                ajaxLoadEffect = self.get("ajaxLoadEffect"),
            //prefixCls = self.get("prefixCls"),
            //arrowCls = prefixCls + "arrow",
                url = ajaxLoadCfg.url,
                loadingHtml = ajaxLoadEffect.loadingHtml,
                loadFailureHtml = ajaxLoadEffect.loadFailureHtml;

            if ((ajaxLoadCfg.refresh && !contentEl.hasClass("loading")) || (!contentEl.hasClass("loading") && !contentEl.hasClass("loaded"))) {
                var resultCode = FGT.core.constant.jsonResultCode;
                if (ajaxLoadCfg.url) {
                    J.ajax({
                        url: url,
                        type: "GET",
                        cache: false,
                        beforeSend: function (jqXHR, settings) {
                            var b = contentEl;
                            b.html(loadingHtml);
                            b.addClass("loading");
                            self.reposition();
                        },
                        success: function (data, textStatus, jqXHR) {
                            var b = contentEl;
                            if (data.Result === resultCode.SUCCESS) {
                                b.html(data.Content);
                                b.addClass("loaded");
                            }
                            else {
                                b.html(loadFailureHtml);
                            }
                            b.removeClass("loading");
                            self.reposition();
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            var b = contentEl;
                            b.html(loadFailureHtml);
                            b.removeClass("loading");
                            self.reposition();
                        }
                    });
                }
            }
        },

        _bindTrigger: function () {
            var self = this,
                trigger = self.get("trigger"),
                timer,
                showArrow = self.get("showArrow");

            self._showPopup = function (event) {
                self._clearHiddenTimer();

                timer = S.later(function () {
                    var alignNode = self.get("alignNode");
                    if (!alignNode) {
                        return;
                    }
                    if (!self.isRender) {
                        self._render();
                    }
                    self._judgeAlign();
                    self._setAlign();
                    if (showArrow) {
                        self._setArrowDirection();
                    }
                    if (self.get("ajaxLoadCfg").enable) {
                        self._ajaxLoad();
                    }
                    self.show();
                    timer = undefined;
                }, self.get("showDelay"));
            };

            trigger.on(self.get("showTriggerType"), self._showPopup);


            self._hidePopup = function () {
                if (timer) {
                    timer.cancel();
                    timer = undefined;
                }

                self._setHiddenTimer();
            };

            trigger.on(self.get("hideTriggerType"), self._hidePopup);
        },

        _bindContainerMouse: function () {
            var self = this;

            self.get('el').on('mouseleave', self._setHiddenTimer, self)
                .on('mouseenter', self._clearHiddenTimer, self);
        },

        _setHiddenTimer: function () {
            var self = this;
            self._hiddenTimer = S.later(function () {
                self.hide();
            }, self.get("hideDelay"));
        },

        _clearHiddenTimer: function () {
            var self = this;
            if (self._hiddenTimer) {
                self._hiddenTimer.cancel();
                self._hiddenTimer = undefined;
            }
        },

        destructor: function () {
            var self = this;
            var t = self.get("trigger");
            if (t) {
                if (self.__showPopup) {
                    t.detach(self.get("showTriggerType"), self._showPopup);
                }
                if (self._hidePopup) {
                    t.detach(self.get("hideTriggerType"), self._hidePopup);
                }
            }
            if (self.get('el')) {
                self.get('el').detach('mouseleave', self._setHiddenTimer, self)
                    .detach('mouseenter', self._clearHiddenTimer, self);
            }
        }
    });


    Component.UIStore.setUIByClass("popup", {
        priority: Component.UIStore.PRIORITY.LEVEL1,
        ui: Popup
    });

    return Popup;
}, {
    requires: ["component", "overlay"]
});KISSY.add("fgt/ui/popbox", function (S, Overlay) {
    function Popbox(config) {
        this._init(config || {});
    }

    S.augment(Popbox, {
        _init: function (config) {
            var self = this;

            self.config = S.merge(
            {
                content: "<span class='text'></span>",
                contentCls: "text"
            }, config);

            self.box = new Overlay({
                prefixCls: "fgt-pb-",
                content: self.config.content,
                elStyle: { position: S.UA.ie == 6 ? "absolute" : "fixed" },
                closable: false,
                mask: true,
                draggable: false,
                zIndex: 999999
            });
        },

        show: function (text, delay, callback, callbackContext, calllbackParams) {
            var self = this,
                box = self.box;

            box.render();   //must invoke render before get "contentEl"
            if (!self.textNode) {
                self.textNode = box.get("contentEl").all("." + self.config.contentCls);
            }
            self.textNode.text(text || "");
            box.center();
            box.show();

            if (delay) {
                S.later(function () {
                    box.hide();
                    if (callback) {
                        callback.apply(callbackContext || this, calllbackParams || []);
                    }
                }, delay);
            }
            else {
                if (callback) {
                    callback.apply(callbackContext || this, calllbackParams || []);
                }
            }
        },

        hide: function () {
            this.box.hide();
        }
    });

    return Popbox;
}, {
    requires: ["overlay"]
});KISSY.add("fgt/ui/imgupload", function (S, Overlay) {
    function ImgUpload(config) {
        var self = this;

        self._init(config || {});
    }

    S.augment(ImgUpload, {
        _init: function (config) {
            var self = this,
                All = S.all;

            self.imgCDNServer = CONFIG["imgCDNServer"];
            self.config = S.merge(
            {
                containerID: "#img_uploader_popup",
                uploadifyID: "img_ufy_popup",
                defaultImgUrl: self.imgCDNServer + "static/img/menu_default.png"
            }, config);

            self.container = All(self.config.containerID);
            self.thumbnail = self.container.all(".thumbnail");
            self.imageTitle = self.container.all(".img-title");
            self.status = self.container.all(".status");
            self.uploadFn = self.container.all(".upload-fn");
            self.saveFn = self.container.all(".save-fn");
            self.saveBtn = self.container.all(".btn-save");
            self.cancelBtn = self.container.all(".btn-cancel");

            self.dialog = new Overlay.Dialog({
                prefixCls: "fgt-",
                srcNode: self.config.containerID,
                elStyle: {
                    position: S.UA.ie == 6 ? "absolute" : "fixed"
                },
                closable: true,
                align: {
                    points: ['cc', 'cc']
                },
                width: 396,
                mask: true,
                draggable: false,
                zIndex: 999999
            });
            self._statusRecover();
            self._bindEvent();

            self.isUploadInit = false;
        },

        _statusRecover: function () {
            var self = this;
            self.thumbnail.attr("src", self.config.defaultImgUrl);
            self.status.empty();
            self.uploadFn.show();
            self.saveFn.hide();
        },

        _uploaderInit: function () {
            var self = this,
                J = jQuery,
                uploadServer = CONFIG["uploadServer"],
                downLoadImageServer = CONFIG["downLoadImageServer"];

            J("#" + self.config.uploadifyID).uploadify({
                "uploader": "/static/flash/uploadify.swf",
                "script": uploadServer,
                "buttonImg": self.imgCDNServer + "static/img/upload/upload2.png",
                "width": 102,
                "height": 28,
                "scriptAccess": "always",
                "queueID": "uploader_queue",
                "queueSizeLimit": 1,
                "auto": true,
                "removeCompleted": false,
                "fileExt": "*.jpg;*.gif;*.png;*.jpeg",
                "scriptData": {
                    "usertype": "1",
                    "source": "/WebPortal/menu",
                    "_G_t": S.Cookie.get("_G_t"),
                    "_G_FA": S.Cookie.get("_G_FA"),
                    "_G_S": S.Cookie.get("_G_S")
                },
                "onSelect": function (event, id, fileObj) {
                    var imgUpload = self;
                    imgUpload.thumbnail.attr("src", imgUpload.config.defaultImgUrl);
                    imgUpload.status.html("<div class='progress'><div class='progress-bar'></div></div>");

                    return false;
                },
                "onCancel": function (event, id, fileObj, data) {
                    return false;
                },
                "onError": function (event, id, fileObj, errorObj) {
                    var imgUpload = self;
                    imgUpload.status.html("<p class='error'>上传失败</p>");

                    return false;
                },
                "onProgress": function (event, id, fileObj, data) {
                    var imgUpload = self,
                        progress = imgUpload.status.all(".progress"),
                        progressBar = progress.all(".progress-bar"),
                        ratio = data.percentage / 100;

                    if (progressBar[0]) {
                        S.Anim(progressBar[0],
                        {
                            'width': ratio * progress.width() + 'px'
                        }, 0.25);
                    }
                    return false;
                },
                "onComplete": function (event, id, fileObj, response, data) {
                    var imgUpload = self,
                        status = imgUpload.status,
                        result = S.JSON.parse(response),
                        resultCode = FGT.core.constant.jsonResultCode;

                    if (result.Result === resultCode.SUCCESS) {
                        var rc = result.Content,
                            imgSrc = downLoadImageServer + "/d/2/"+ rc.id + "(120x90).jpg";

                        self.imageStoreID = rc.id;
                        self.thumbnail.attr("src", imgSrc);
                        status.html("<p>上传成功！</p>");
                        imgUpload.uploadFn.hide();
                        imgUpload.saveFn.show();
                    }
                    else {
                        status.html("<p class='error'>上传失败</p>");
                    }
                    return false;
                }

            });

            self.isUploadInit = true;
        },

        _bindEvent: function () {
            var self = this,
                All = S.all;
            self.dialog.on("beforeVisibleChange", function (event) {
                if (event.newVal) {
                    self._statusRecover();
                }
                else {
                    All("#" + self.config.uploadifyID + "Uploader").css("visibility", "hidden");
                }
            });

            self.dialog.on("show", function (event) {
                if (!self.isUploadInit) {
                    self._uploaderInit();
                }
                All("#" + self.config.uploadifyID + "Uploader").css("visibility", "visible");
            });

            self.cancelBtn.on("click", function (event) {
                event.halt();
                self.dialog.hide();
            });

            self.saveBtn.on("click", function (event) {
                event.halt();
                var callback = self.config.saveCallback;
                if (callback) {
                    callback.call(self.config.context || self);
                }
            });
        },



        show: function (text, delay) {
            this.dialog.show();

        },

        hide: function () {
            this.dialog.hide();
        },

        setImageTitle: function (imageTitle) {
            this.imageTitle.text(imageTitle || "");
        },

        save: function (config) {
            var self = this,
                J = jQuery,
                paramStr = S.param(S.merge({ imageid: self.imageStoreID }, self.submitObj));

            J.ajax({
                url: config.url,
                type: "POST",
                data: paramStr,
                beforeSend: function (jqXHR, settings) {
                    self.saveBtn.prop("disabled", true);
                    self.status.html("<p>提交中...</p>");
                },
                success: function (data, textStatus, jqXHR) {
                    var resultCode = FGT.core.constant.jsonResultCode,
                        redirectUrl = self.redirectUrl;
                    if (data.Result === resultCode.SUCCESS) {
                        self.hide();
                        if (redirectUrl) {
                            window.location.href = redirectUrl;
                        }
                    }
                    else {
                        self.status.html("<p class='error'>提交失败，请稍候再试。</p>");
                    }
                    self.saveBtn.prop("disabled", false);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    self.status.html("<p class='error'>提交失败，请稍候再试。</p>");
                    self.saveBtn.prop("disabled", false);
                }
            });
        },

        setConfig: function (name, value) {
            this.config[name] = value;
        },
        setSaveData: function (submitObj) {
            this.submitObj = submitObj;
        },
        setRedirectUrl: function (redirectUrl) {
            this.redirectUrl = redirectUrl;
        }
    });

    return ImgUpload;
}, {
    requires: ["overlay"]
});KISSY.add("fgt/ui/confirm", function (S, Overlay) {
    function Confirm(config) {
        this._init(config || {});
    }

    S.augment(Confirm, {
        _init: function (config) {
            var self = this;

            self.config = S.merge(
            {
                content: "<div class='confirm-panel'>"
                            + "<p class='text'></p>"
                            + "<div class='fn'>"
                                + "<a class='button1 cfm-save'>确定</a>"
                                + "<a class='button6 cfm-cancel'>取消</a>"
                            + "</div>"
                         + "</div>",
                textCls: "text"
            }, config);

            self.dialog = new Overlay.Dialog({
                prefixCls: "fgt-",
                bodyContent: self.config.content,
                elStyle: {
                    position: S.UA.ie == 6 ? "absolute" : "fixed"
                },
                elCls: "fgt-confirm",
                closable: true,
                align: {
                    points: ['cc', 'cc']
                },
                width: 300,
                mask: true,
                draggable: false,
                zIndex: 999999
            });
            self.isRender = false;
        },

        _bindEvent: function () {
            var self = this;

            self.confirmBtn.on("click", function (event) {
                event.halt();
                self.dialog.hide();
                var callback = self.comfirmCallback;
                if (callback) {
                    callback.apply(self.callbackContext || self, self.confirmCallBackParams || []);
                }
            });

            self.cancelBtn.on("click", function (event) {
                event.halt();
                self.dialog.hide();
            });
        },

        _render: function () {
            var self = this,
                dialog = self.dialog,
                contentEl;

            dialog.render();
            contentEl = dialog.get("contentEl");
            self.textNode = contentEl.all("." + self.config.textCls);
            self.confirmBtn = contentEl.all(".cfm-save");
            self.cancelBtn = contentEl.all(".cfm-cancel");

            self._bindEvent();
            self.isRender = true;
        },

        show: function (text, confirmCallback, callbackContext, confirmCallBackParams) {
            var self = this;

            if (!self.isRender) {
                self._render();
            }
            self.comfirmCallback = confirmCallback;
            self.callbackContext = callbackContext;
            self.confirmCallBackParams = confirmCallBackParams;
            self.textNode.text(text || "");
            self.dialog.show();
        },

        hide: function () {
            this.dialog.hide();
        }
    });

    return Confirm;
}, {
    requires: ["overlay"]
});KISSY.add("fgt/ui/labelcloud", function (S) {
    function LabelCloud(id) {
        var self = this;
        self._init(id);
    }

    S.augment(LabelCloud, {
        _init: function (id) {
            var self = this,
                $ = S.all,
                container = $(id);
            self.container = container;
            self.width = container.width();
            self.height = container.height();

            self.rectArray = [];
        },

        _rand: function (num) {
            return parseInt(num * Math.random());
        },

        _add: function (node) {
            var self = this,
                cw = self.width,
                ch = self.height,
                w, h, left, top, right, bottom,
                tryCount = 20;
            w = node.width();
            h = node.height();
            left = self._rand(cw - w);
            top = self._rand(ch - h);
            right = left + w;
            bottom = top + h;

            while (self._check(left, top, right, bottom) === false) {
                left = self._rand(cw - w);
                top = self._rand(ch - h);
                right = left + w;
                bottom = top + h;

                if (--tryCount <= 0) {
                    break;
                }
            }

            node.css({ top: top, left: left, display: "block", position: "absolute" });
            self.rectArray.push({ left: left, top: top, right: right, bottom: bottom });


        },

        _check: function (left, top, right, bottom) {
            var self = this,
                rectArray = self.rectArray,
                i;
            for (i = 0; i < rectArray.length; ++i) {
                if (self._isIntersect(rectArray[i], { left: left, top: top, right: right, bottom: bottom }) === true) {
                    return false
                }
            }
            return true;
        },

        _isIntersect: function (rect1, rect2) {
            var maxLeft = Math.max(rect1.left, rect2.left),
                maxTop = Math.max(rect1.top, rect2.top),
                minRight = Math.min(rect1.right, rect2.right),
                minBottom = Math.min(rect1.bottom, rect2.bottom);

            if (maxLeft > minRight || maxTop > minBottom) {
                return false;
            }
            else {
                return true;
            }
        },

        render: function () {
            var self = this,
                container = self.container,
                labelItems = container.all(".label-item");

            labelItems.each(function (item) {
                self._add.call(self, item);
            }, self);
        }
    });

    return LabelCloud;
});KISSY.add("fgt/ui/imggallary", function (S, Overlay) {
    function ImgGallary(config) {
        this._init(config || {});
    }

    S.augment(ImgGallary, {
        _init: function (config) {
            var self = this;

            self.config = S.merge(
            {
                titleCls: "title",
                prevPanelCls: "prev-panel",
                nextPanelCls: "next-panel",
                prevArrowCls: "prev-arrow",
                nextArrowCls: "next-arrow",
                imgPanelCls: "img-panel",
                imgWidth: 524,
                imgHeight: 393,
                boxWidth: 536
            }, config);

            if (!S.isArray(self.config.data)) {
                S.log("请配置正确的data.", "error");
                return;
            }

            self.box = new Overlay({
                prefixCls: "fgt-",
                srcNode: self.config.containerID,
                elStyle: { position: S.UA.ie == 6 ? "absolute" : "fixed" },
                closable: true,
                width: self.config.boxWidth,
                mask: true,
                draggable: false,
                zIndex: 999999
            });

            self._isRendered = false;
            self.currentImgIndex = -1;
        },

        _bindEvent: function () {
            var self = this,
                box = self.box,
                All = S.all,
                contentEl = box.get("contentEl"),
                cfg = self.config;

            self.title = contentEl.all("." + cfg.titleCls);
            self.prevPanel = contentEl.all("." + cfg.prevPanelCls);
            self.nextPanel = contentEl.all("." + cfg.nextPanelCls);
            self.prevArrow = contentEl.all("." + cfg.prevArrowCls);
            self.nextArrow = contentEl.all("." + cfg.nextArrowCls);
            self.imgPanel = contentEl.all("." + cfg.imgPanelCls);

            self.prevPanel.on("mouseenter", function (event) {
                self.prevArrow.show();
            });

            self.prevPanel.on("mouseleave", function (event) {
                self.prevArrow.hide();
            });

            self.prevPanel.on("click", function (event) {
                var toIndex = self.currentImgIndex - 1;
                if (toIndex < 0 || toIndex >= self.config.data.length) {
                    return;
                }
                self._updateStatus(toIndex);
            });

            self.nextPanel.on("mouseenter", function (event) {
                self.nextArrow.show();
            });

            self.nextPanel.on("mouseleave", function (event) {
                self.nextArrow.hide();
            });

            self.nextPanel.on("click", function (event) {
                var toIndex = self.currentImgIndex + 1;
                if (toIndex < 0 || toIndex >= self.config.data.length) {
                    return;
                }
                self._updateStatus(toIndex);
            });
        },

        _updateStatus: function (currentIndexNum) {
            var self = this,
                cfg = self.config,
                data = cfg.data,
                currentImgData = data[currentIndexNum],
                displayIndex = currentIndexNum + 1;

            self.imgPanel.attr("src", CONFIG["downLoadImageServer"] + "/d/2/" + currentImgData.id + "(" + cfg.imgWidth + "x" + cfg.imgHeight + ")" + ".jpg");
            self.imgPanel.attr("alt", currentImgData.name);
            self.title.text(currentImgData.name + "(" + displayIndex + "/" + data.length + ")");
            self.currentImgIndex = currentIndexNum;

            if (currentIndexNum > 0) {
                self.prevPanel.show();
            }
            else {
                self.prevPanel.hide();
                self.prevArrow.hide();
            }

            if (currentIndexNum < data.length - 1) {
                self.nextPanel.show();
            }
            else {
                self.nextPanel.hide();
                self.nextArrow.hide();
            }

        },

        show: function (index) {
            var self = this,
                box = self.box,
                cfg = self.config,
                data = cfg.data,
                indexNum = parseInt(index);

            if (indexNum < 0 || indexNum >= data.length) {
                return;
            }

            if (!self._isRendered) {
                box.render();
                self._bindEvent();
                self._isRendered = true;
            }
            self._updateStatus(indexNum);

            box.center();
            box.show();
        },

        hide: function () {
            this.box.hide();
        }
    });

    return ImgGallary;
}, {
    requires: ["overlay"]
});KISSY.add("fgt/ui", function (S, Popup, Popbox, ImgUpload, Confirm, LabelCloud, ImgGallary) {

    S.namespace("FGT.ui", true);

    S.mix(S.FGT.ui, {
        Popup: Popup,
        Popbox: Popbox,
        ImgUpload: ImgUpload,
        Confirm: Confirm,
        LabelCloud: LabelCloud,
        ImgGallary: ImgGallary,
        getPopbox: function () {
            if (S.isUndefined(FGT.globalObj.popbox)) {
                FGT.globalObj.popbox = new Popbox();
            }
            return FGT.globalObj.popbox
        },
        getConfirm: function () {
            if (S.isUndefined(FGT.globalObj.confirm)) {
                FGT.globalObj.confirm = new Confirm();
            }
            return FGT.globalObj.confirm
        }
    });
    
    return S.FGT.ui;

}, { requires: ["./ui/popup", "./ui/popbox", "./ui/imgupload", "./ui/confirm", "./ui/labelcloud", "./ui/imggallary"] });